package it.lujunfa.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;

import it.lujunfa.aop.MyAnntation;
import it.lujunfa.aop.math;
import it.lujunfa.aop.mathAnntation;
import it.lujunfa.service.impl.JedisServiceImpl;
import it.lujunfa.service.impl.RedisCacheUtil;
import it.lujunfa.vo.User;
import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode.ArrayUnit;


@RequestMapping(value="/main/set")
@Controller
public class MainController {
   @Autowired
   JedisServiceImpl jedisServiceImpl;
   @Autowired
   RedisCacheUtil redisCacheUtil;
   @Resource
   math math;
   @Autowired
   mathAnntation mathAnntation;
   @RequestMapping("/toTest")
   @MyAnntation
   public String toTest(){
	  /* int d=10;
	   jedisServiceImpl.addString("lujunchao", "my brother!");
	   System.err.println("============redis:"+jedisServiceImpl.queryString("lujunchao")+d);*/
	   redisCacheUtil.setCacheObject("province", "hunan");
	   System.err.println("============redis:"+redisCacheUtil.getCacheValue("province"));
	   
	   redisCacheUtil.setCacheList("my_famliy",Arrays.asList("lujunfa","lujunchao","ludesheng","liangdongxiu"));
	   System.err.println("============redisList:"+redisCacheUtil.getCacheList("my_famliy").get(1));

	   Map<String,String> map=new HashMap<String, String>();
	   map.put("name", "nixi");
	   map.put("age", "21");
	   map.put("sex", "female");
	   redisCacheUtil.setCacheMap("gf", map);
	   System.err.println("============redisMapCache:"+redisCacheUtil.getCacheMap("gf").get("sex"));

	   
	   int n1 = 100, n2 = 5;
       math.add(n1, n2);
       math.sub(n1, n2);
       math.mut(n1, n2);
       math.div(n1, n2);
       
       mathAnntation.add(n1, n2);
       mathAnntation.sub(n1, n2);
       mathAnntation.mut(n1, n2);
       mathAnntation.div(n1, n2);
	   return "test/test";
   }
}
